/*
 *    Copyright (c) 2018-2025, shenghua All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: shenghua
 */

package com.chen.common.security.info;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.SpringSecurityCoreVersion;
import org.springframework.security.core.userdetails.User;

import java.util.Collection;

/**
 * @author UserInfo
 * @date 2020/4/16 扩展用户信息
 */
@Getter
public class UserInfo extends User {

	private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;

	/**
	 * 用户ID
	 */
	private Integer userId;

	/**
	 * 手机号
	 */
	private String phone;

	/**
	 * 账户类型
	 */
	private String accountType;

	/**
	 * @param userId                用户ID
	 * @param phone					账户手机号
	 * @param username              账户名称
	 * @param password              账户密码
	 * @param enabled               如果账户已启用，则设置为<code>true</code>
	 * @param accountNonExpired     如果账户尚未过期，则设置为<code>true</code>
	 * @param credentialsNonExpired 如果凭据尚未过期，则设置为<code>true</code>
	 * @param accountNonLocked      如果账户未锁定，则设置为<code>true</code>
	 * @param authorities           权限集
	 * @param accountType			账户类型
	 */
	@JsonCreator
	public UserInfo(@JsonProperty("userId") Integer userId,
					@JsonProperty("phone") String phone,
					@JsonProperty("username") String username,
					@JsonProperty("password") String password,
					@JsonProperty("enabled") boolean enabled,
					@JsonProperty("accountNonExpired") boolean accountNonExpired,
					@JsonProperty("credentialsNonExpired") boolean credentialsNonExpired,
					@JsonProperty("accountNonLocked") boolean accountNonLocked,
					@JsonProperty("authorities") Collection<? extends GrantedAuthority> authorities,
					@JsonProperty("accountType") String accountType) {
		super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
		this.userId = userId;
		this.phone = phone;
		this.accountType = accountType;
	}
}
